<template>
  <div class="on-study-boox">
    <nav-bar :title="'培训课程'"></nav-bar>
    <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
      <award-item :list="list"></award-item>
    </van-list>
  </div>
</template>

<script>
import noData from '@/components/noData/index.vue'
import navBar from '@/components/NavBar'
import awardItem from '@/components/award/awardItem'
export default {
  name: 'ActivityList',
  components: {
    navBar,
    navBar,
    awardItem,
  },
  data() {
    return {
      list: [],
      loading: false,
      finished: false,
      param: {
        page: 0,
        pageSize: 20,
      },
    }
  },
  methods: {
    onLoad() {
      this.init()
    },
    init() {
      this.param.page++
      this.$request({
        url: '/course/findCourseList',
        method: 'post',
        data: this.param,
      }).then((rsp) => {
        console.log(rsp.data.list, 'www')
        if (rsp.code === 200) {
          // titleImg
          rsp.data.list.forEach((item) => {
            item.titleImg = item.listImage
            item.title = item.courseTitle
            item.path = 'studyDetails'
            item.awardId = item.courseId
          })
          if (this.param.page === 1) {
            this.list = rsp.data.list
          } else {
            this.list.splice(-1, 0, ...rsp.data.list)
          }
          this.loading = false
          if (this.list.length >= rsp.data.total) {
            this.finished = true
          } else {
            this.finished = false
          }
        } else {
          this.$toast.fail(rsp.content)
        }
      })
    },
  },
  mounted() {},
}
</script>

<style lang='scss'>
@import '../assets/css/base';
.on-study-boox {
  padding: 0 px2rem(30);
}
</style>
